{# empty Twig template #}
{% extends "EMNewsBundle::layout.html.twig" %}
{% block title 'Language Selection' %}
{% block middlenav%}
<div class="middleNav">
    	<ul>
           <li class="iList"><a href="{{ path('em_category_list') }}" title=""><span>List</span></a></li>
	</ul>
</div>
{% endblock%}


{% block content %}
<fieldset>
  
   <div class="widget">
   <div class="head"><h5 class="iHome">Assign Countries and Languages to the following user:</h5></div>
     {{ form_start(form, {'attr': {'class': 'mainForm', 'id': 'valid'}}) }}
   <div class="supTicket nobg">
                        <div class="issueSummary">
                            <a href="#" title="" class="floatleft"><img src="{{asset('uploads/images/users/')}}{{user.file}}" alt="" width="37px" height="36px"></a>	
                             <div class="fix"></div>
                        </div> 
                    	<div class="issueType">
                        	<span class="issueInfo"><a href="#" title="">{{user.firstname}} {{user.lastname}}</a> [ @{{user.username}} ]</span>
                            <div class="fix"></div>
                        </div>
     {{ form_widget(form.geo)}}<div id="loadergift"></div>
   </div>
   <div class="rowElem" id="langList">
   
        {% include 'EMNewsBundle:User:listLanguagesAjax.html.twig' %}
	
    <div class="fix"></div>
   </div>
   <div class="rowElem">
       <input type="hidden" name="userid" value="{{user.id}}">
   <input type="submit" id="valid" value="Save Languajes">
   </div>
    {{ form_end(form) }}          
  
   </div>
</fieldset>
<fieldset>
   {% include 'EMNewsBundle:User:tableSettings.html.twig' %}
  
</fieldset>
<script>
$( "#valid" ).submit(function( event ) {
 
 var action= '{{path('em_user_save_geo_lang')}}';
 console.log(action);  
 var datos = $(this).serialize();     
 console.log(datos);  
 $.ajax({type: 'POST', url:action, script:true, cache:true,data: datos,
                    beforeSend: function(response){ console.log('<div align="center"><img src="{{asset('bundles/news/images/loaders/loader8.gif')}}" alt="" class="p12"><br>Loading data...</div>');},
                    error: function(response){console.log("error".response);},
                    success: function(response) {
			if (response === "false"){

			}else{
                        console.log(response);
                        //$('#formcontent').html(response);
                        
			}
                } });
        return false;
 
 
});

$('#lang_form_geo').change(function(){
var id=$(this).val();
if(id!=="")
    {
var action= '{{ path('em_user_geo_combo',{'countryid':'value'}) }}';
action = action.replace("value", id);
console.log(action)
$.ajax({type: 'POST', url:action, script:true, cache:true,
                    beforeSend: function(response){ $('#loadergift').html('<img src="{{asset('bundles/news/images/loaders/loader5.gif')}}" alt="" class="p12">'); $('#langList').html("");},
                    error: function(response){console.log(response);},
                    success: function(response) {
			if (response === "false"){

			}else{
                        //console.log(response);
                        $('#langList').html(response);
                        $('#loadergift').html("");
                        
			}
                } });
            }
            else
            {
            $('#langList').html('Select an option');
            }
});

</script>
{% endblock %}		